package com.bookhouse.service.impl;

import java.util.List;

import com.bookhouse.dao.ReaderTypeDao;
import com.bookhouse.domain.ReaderType;
import com.bookhouse.service.ReaderTypeService;

public class ReaderTypeServiceImpl implements ReaderTypeService {

	ReaderTypeDao readerTypeDao;

	public void setReaderTypeDao(ReaderTypeDao readerTypeDao) {
		this.readerTypeDao = readerTypeDao;
	}

	@Override
	public void saveReaderType(ReaderType readerType) {
		if (readerType.getId() != null && readerType.getId() > 0)
			readerTypeDao.update(readerType);
		else
			readerTypeDao.save(readerType);
	}

	@Override
	public List<ReaderType> getAllReaderType() {
		return readerTypeDao.findAll(ReaderType.class);
	}

	@Override
	public ReaderType getReaderType(int id) {
		return readerTypeDao.get(ReaderType.class, id);
	}

	@Override
	public void deleteReaderType(int id) {
		readerTypeDao.delete(ReaderType.class, id);
	}

}
